package com.cat.dataStructure03;

/**
*   @description https://leetcode.cn/problems/number-of-substrings-with-only-1s/?envType=daily-question&envId=2025-11-16
*   @author 曲大人的喵
*   @create 2025/11/16 09:46
*   @since JDK17
*/

public class Solution63 {
    public int numSub(String s) {
        long ans = 0;
        int n = s.length(), N = ((int) 1e9) + 7;
        for (int l = 0, r = 0; r < n; r++) {
            if (s.charAt(r) == '1') {
                ans = (ans +  r - l + 1) % N;
            } else {
                l = r + 1;
            }
        }

        return ((int) ans);
    }
}
